home *** CD-ROM | disk | FTP | other *** search
- package java.lang;
-
- import java.util.IdentityHashMap;
- import java.util.Set;
-
- class ApplicationShutdownHooks implements Runnable {
- private static ApplicationShutdownHooks instance = null;
- private static IdentityHashMap<Thread, Thread> hooks = new IdentityHashMap();
-
- static synchronized ApplicationShutdownHooks hook() {
- if (instance == null) {
- instance = new ApplicationShutdownHooks();
- }
-
- return instance;
- }
-
- private void ApplicationShutdownHooks() {
- }
-
- static synchronized void add(Thread var0) {
- if (hooks == null) {
- throw new IllegalStateException("Shutdown in progress");
- } else if (var0.isAlive()) {
- throw new IllegalArgumentException("Hook already running");
- } else if (hooks.containsKey(var0)) {
- throw new IllegalArgumentException("Hook previously registered");
- } else {
- hooks.put(var0, var0);
- }
- }
-
- static synchronized boolean remove(Thread var0) {
- if (hooks == null) {
- throw new IllegalStateException("Shutdown in progress");
- } else if (var0 == null) {
- throw new NullPointerException();
- } else {
- return hooks.remove(var0) != null;
- }
- }
-
- public void run() {
- Set var1;
- synchronized(ApplicationShutdownHooks.class) {
- var1 = hooks.keySet();
- hooks = null;
- }
-
- for(Thread var3 : var1) {
- var3.start();
- }
-
- for(Thread var9 : var1) {
- try {
- var9.join();
- } catch (InterruptedException var5) {
- }
- }
-
- }
- }
-